package TraitementMessages;

import com.lo23.data.objgroup.*;
import java.util.logging.*;
import com.lo23.data.objinterface.*;
import java.util.*;
import ihm.main.Traitement;
import mainProcess.MainProcessing;

/**
 * @class FriendRequestMessage
 * @author Hicham & Maryam
 */
public class FriendRequestMessage extends FriendMessage {
	
	static final long serialVersionUID = 23201010L;

    private java.lang.String senderLogin;
   
    public FriendRequestMessage(String senderUID,String senderLogin)
    {
    	super(senderUID);
		this.senderLogin = senderLogin;
    }
    
	public void setLogin (String senderLogin) {
        this.senderLogin = senderLogin;
	}

    public String getLogin () {
        return senderLogin;
    }

    public void handleReceiption(MainProcessing mainProcessing) 
    {
    	   	       
    	

    	LocalUser lUser = mainProcessing.getDataInterface().getLocalUser(null);

    	if(lUser == null)
    	{
    		Logger.getLogger(FriendRequestMessage.class.getName()).log(Level.SEVERE, "Traitement : Local user Null");
    		return ;
    	}
    	
        
    	// enregister la requete de l'ami
        FriendshipAnswer frRequest = lUser.addUnsentFriendAnswer();
        
        frRequest.setFriendID(senderUID);
        frRequest.setFriendLogin(senderLogin);
        frRequest.setStatus(false);
        frRequest.setDate(new Date());

		Traitement interfaceIHM = Traitement.getInstance();
		interfaceIHM.friendRequest(senderUID);
        
    }
        
        

        

    	
    	

    
}
